package cn.iocoder.yudao.module.trade.delivery.vo;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.region.RegionUtils;
import cn.iocoder.yudao.framework.region.vo.setter.CountyAutoSetter;
import cn.iocoder.yudao.module.api.infrastructure.user.dto.AdminUserSimpleRespDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - 自提门店 Response VO")
@Data
public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO implements CountyAutoSetter {

    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128")
    private Long id;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;

    @Schema(description = "核销用户数组", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<AdminUserSimpleRespDTO> verifyUsers;

    @Schema(description = "省份编码", example = "520000")
    private String provinceCode;

    @Schema(description = "省份名称", example = "贵州省")
    private String provinceName;

    @Schema(description = "城市编码", example = "520100")
    private String cityCode;

    public String getCountyCode() {
        if (StrUtil.isBlank(countyCode)) {
            return RegionUtils.convertRegionIdToCode(getAreaId());
        }
        return countyCode;
    }

    @Schema(description = "城市名称", example = "贵阳市")
    private String cityName;

    @Schema(description = "区县编码", example = "520100")
    private String countyCode;

    @Schema(description = "区县名称", example = "南明区")
    private String countyName;

    @Schema(description = "完整地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "贵州省贵阳市南明区花果园金融街5号驰通集团公司")
    private String fullAddress;

    @SuppressWarnings("unused")
    public String getFullAddress() {
        return getProvinceName() + getCityName() + getCountyName() + getDetailAddress();
    }

}
